package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author ：Shine
 * @description：
 * @date ：2021/3/22 20:32
 */
@RestController
@RequestMapping("customer")
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    // http://localhost:8080 /customer/list
    @PostMapping("list")
    @RequiresPermissions(value = "客户管理")
    public Map<String, Object> listCustomer(Integer page, Integer rows, String customerName) {
        return customerService.listCustomer(page, rows, customerName);
    }

    //    http://localhost:8080/ customer/save?customerId=1
    @PostMapping("save")
    @RequiresPermissions(value = "客户管理")
    public ServiceVO saveCustomer(Customer customer) {
        return customerService.saveCustomer(customer);
    }

    //    http://localhost:8080/customer/delete
    @PostMapping("/delete")
    @RequiresPermissions("客户管理")
    public ServiceVO delete(String ids) {
        return customerService.delete(ids);
    }
}
